home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byte0787.arc / IWPAS.ARC / THRESH.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-04-28  |  1.5 KB  |  58 lines

  1. PROGRAM Thresh(input,output,picfile);
  2.  
  3. { Copyright (c) 1987, Ciarcia's Circuit Cellar          }
  4. {    All Rights Reserved                                }
  5.  
  6. {$U- control-break checking during execution            }
  7. {$C- control-break checking during I/O operations       }
  8. {$R- array range checking                               }
  9.  
  10. {$Ideclares.p                   declarations            }
  11. {$Ihexutil.p                    hex utilities           }
  12. {$Iserial.p                     serial interface code   }
  13. {$Ipictures.p                   picture file code       }
  14. {$Iimages.p                     image processing        }
  15.  
  16. VAR
  17.  level     : INTEGER;
  18.  valerror  : INTEGER;
  19.  
  20. BEGIN
  21.  
  22.  LowVideo;
  23.  
  24.  pic1 := NIL;                   { ensure new alloc      }
  25.  PicSetup(pic1);                { set up picture array  }
  26.  
  27.  filespec := GetFSpec(ParamStr(1));
  28.  
  29.  LoadPicture(filespec,pic1);
  30.  
  31.  IF Length(ParamStr(2)) = 0
  32.   THEN BEGIN
  33.    Write('Threshold (0-63): ');
  34.    Readln(level);
  35.    IF level > 63
  36.     THEN level := 63;
  37.    IF level < 0
  38.     THEN level := 0;
  39.    valerror := 0;
  40.   END
  41.   ELSE Val(ParamStr(2),level,valerror);
  42.  
  43.  IF valerror <> 0
  44.   THEN BEGIN
  45.    Writeln('Threshold must be numeric: ',ParamStr(2));
  46.    Halt;
  47.   END;
  48.  
  49.  Writeln('Thresholding...');
  50.  Threshold(pic1,level);
  51.  
  52.  IF ParamStr(3) <> ''
  53.   THEN filespec := ParamStr(3);
  54.  
  55.  SavePicture(filespec,pic1);
  56.  
  57. END.
  58.